/**
 * 商家信息服务
 */

import { BaseApiService } from '../utils/api';
import {
  MerchantAddDto,
  MerchantAddVo,
} from '../types/api';

export interface MentorListParams {
  merchantId?: number;
  pageNum?: number;
  pageSize?: number;
}

export class MerchantService extends BaseApiService {
  
  /**
   * 添加商家信息
   */
  async addMerchant(data: MerchantAddDto): Promise<MerchantAddVo> {
    return this.handleResponse(
      this.http.post<MerchantAddVo>('/api/merchant/add', data)
    );
  }

  /**
   * 查询商家下的导师列表（含头像/姓名/电话/资格证书/导师审核状态），支持分页
   */
  async getMentorList(params: MentorListParams = {}): Promise<any> {
    const { merchantId, pageNum = 1, pageSize = 10 } = params;
    return this.handleResponse(
      this.http.get<any>('/api/merchant/mentor/list', {
        merchantId,
        pageNum,
        pageSize,
      })
    );
  }

  /**
   * 删除商家-导师关联
   */
  async deleteMentorAssociation(id: number): Promise<boolean> {
    return this.handleResponse(
      this.http.delete<boolean>(`/api/merchant/mentor/delete/${id}`)
    );
  }
}

// 导出单例实例
export const merchantService = new MerchantService();
